package 计时器;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-09-26
 * Time: 15:49
 */
public class Time {
    public static void main(String[] args) {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {//TimerTask就是一个Runnable接口,重写run方法,改线程要执行的任务
            @Override
            public void run() {
                System.out.println("时间到了!!!快起床!!!");
            }
        },3000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("1");
            }
        },4000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("2");
            }
        },5000);
        System.out.println("开始计时");

    }
}
